package org.dev.vlp.utils;

import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import org.dev.vlp.exception.ApiException;

import java.util.Collection;
import java.util.Objects;

/**
 * Description
 * Param
 * return
 * Author:86184
 * Date: 2023/1/11
 */
public class AssertUtils {
    public static void notNull(Object object, String message) {
        if (Objects.isNull(object)) {
            throw new ApiException(message);
        }
    }

    public static void notBlank(String str, String message) {
        if (StringUtils.isBlank(str)) {
            throw new ApiException(message);
        }
    }

    public static void isTrue(Boolean expression, String message) {
        if (!expression) {
            throw new ApiException(message);
        }
    }

    public static void isFalse(Boolean expression, String message) {
        if (expression) {
            throw new ApiException(message);
        }
    }

    public static void equals(Object a, Object b, String message) {
        if (!Objects.equals(a, b)) {
            throw new ApiException(message);
        }
    }

    public static void notEmpty(Collection collection, String message) {
        if (collection == null || collection.size() == 0) {
            throw new ApiException(message);
        }
    }
}
